#include "AtmoSphere.h"
#include "../Global References/Globals.h"
#include "../Engine/Engine.h"



void AtmoSphere::init()
{
	pSky = new BaseObject;
	spinSpeed.init(-10);
	
	setScale(-5, 5, 5);
	pSky->setScale(8.5, 8.5, 8.5);
	SetPos(0,-6840,280);
	setRotation(0,0,0);
	pSky->SetPos(getPos().x, getPos().y, getPos().z + 200);

	objectType = TYPE_PLAYER_PIECE;
	
	//HACK TO PREVENT WORLD TUBE FROM LOADING IN DIRTY DRAWLISTS :[
	Engine::Ins()->graphics.AddAsset
		("Resources/Meshes/container.x", 
		 "Resources/Sprites/Alpha.png", NULL, NULL, ASSET_WORLD);
	
	assetIndex = Engine::Ins()->graphics.AddAsset
		("Resources/Meshes/container.x", 
		 "Resources/Sprites/Grid.jpg", NULL, NULL, ASSET_WORLD);
	Engine::Ins()->dlHandler.AddObject(this, DRAW_ENTITIES);

	pSky->objectType = TYPE_PLAYER_PIECE;
	pSky->assetIndex = Engine::Ins()->graphics.AddAsset(
		"Resources/Meshes/sky.x", 
		"Resources/Sprites/sky.jpeg", NULL, NULL, ASSET_WORLD);
	Engine::Ins()->dlHandler.AddObject(pSky, DRAW_ENTITIES);
}
void AtmoSphere::update(Vector3D Pos)
{
	SetPos(Pos.x,-6840,10);
	pSky->SetPos(getPos().x, getPos().y, getPos().z + 200);
	if(spinSpeed.update())
	{
		Vector3D x = getRotation();
		setRotation(x.x,x.y+g_AtmSpin,x.z);
	};

}

void AtmoSphere::release()
{
	if(pSky)
	{
		delete pSky;
		pSky = NULL;
	}
}